package com.example.yin.controller;

import com.example.yin.common.aop.MyLog;
import com.example.yin.domain.Consumer;
import com.example.yin.service.CaptchaService;
import com.example.yin.service.LoginService;
import com.example.yin.vo.LoginParamVo;
import com.example.yin.vo.LoginVO;
import com.example.yin.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class LoginController {

    @Autowired
    private LoginService loginServcie;

    @Autowired
    private CaptchaService captchaService;

    private LoginVO loginVO;



    @MyLog(value = "登陆")
    @PostMapping("/login")
    public Object login(Consumer user){
//        String msg = captchaService.checkImageCode(loginVO.getNonceStr(),loginVO.getValue());
//        if (StringUtils.isNotBlank(msg)) {
//            throw new RuntimeException("验证码不正确");
//        }
        return loginServcie.login(user);
    }

    @RequestMapping("/user/logout")
    public Object logout(){
        return loginServcie.logout();
    }

    @PostMapping("/findPassword")
    public R findPassword(@RequestBody LoginParamVo loginParamVo) {

        return loginServcie.findPassword(loginParamVo);
    }

}


